home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Music / MISC / MusicalDiceGame / Programmers / DiceCommand.c < prev    next >
C/C++ Source or Header  |  1995-08-23  |  1KB  |  65 lines

  1.  
  2. #include <exec/types.h>
  3. #include <exec/ports.h>
  4. #include <proto/exec.h>
  5.  
  6. #define PORT_NAME    "MusicalDiceGame_Port"
  7.  
  8. struct MsgPort *ZuluPortP;
  9.  
  10.  
  11. #define ACT_QUIT    1
  12. #define ACT_PLAY    2
  13. #define ACT_STOP    3
  14. #define ACT_CONTINUE     4
  15. #define ACT_NEW        5
  16.  
  17. struct Musical_Message {
  18.  
  19.     struct Message mdg_Message;
  20.     UWORD        mdg_Action;        /* see above */
  21.     UWORD       mdg_Unused;
  22. };
  23.  
  24. struct Musical_Message    ask;
  25.  
  26.  
  27.  
  28. main(int argc, char **argv) {
  29.  
  30.     UWORD    action = 0;
  31.  
  32.     if (argc != 2) {
  33.     printf("Usage: DiceCommand [quit|play|stop|continue|new]\n");
  34.     exit(NULL);
  35.     }
  36.  
  37.     /* select command */
  38.     if (strcmp(argv[1],"quit") == 0) action = ACT_QUIT;
  39.     if (strcmp(argv[1],"play") == 0) action = ACT_PLAY;
  40.     if (strcmp(argv[1],"stop") == 0) action = ACT_STOP;
  41.     if (strcmp(argv[1],"continue") == 0) action = ACT_CONTINUE;
  42.     if (strcmp(argv[1],"new") == 0) action = ACT_NEW;
  43.  
  44.     if (! action) {
  45.     printf("Usage: DiceComm [quit|play|stop|continue|new]\n");
  46.     exit(NULL);
  47.     }
  48.  
  49.     ask.mdg_Message.mn_Length = sizeof(struct Musical_Message);
  50.     ask.mdg_Action = action;
  51.  
  52.     Forbid();
  53.  
  54.     /* find Musical Dice Game message port */
  55.         ZuluPortP = FindPort(PORT_NAME);
  56.  
  57.     if (ZuluPortP) {
  58.         PutMsg(ZuluPortP, &ask);        /* send command */
  59.     }
  60.     else {
  61.         printf("Musical Dice Game not active.\n");
  62.     }    
  63.     Permit();
  64. }
  65.